#ifndef SCHEDULER_HEADER_H
#define SCHEDULER_HEADER_H

#include "noncopyable.hpp"
#include "SQL_util.h"
#include "task_util.h"

class Scheduler : public NonCopyable {

    HWND    hwnd_notify_;
    UINT    sched_interv_;
    HANDLE  hthr_sched_;
    SQLutil &task_db_;

protected:

    static DWORD WINAPI schedule_task_proc(LPVOID);

    Scheduler(HWND hwnd, SQLutil &db, UINT interv);

    void do_schedule();

    void post_task(std::vector<Task> & tasks);

    ~Scheduler()
    { }

public:

    static Scheduler & createScheduler(HWND hwnd, SQLutil &db, UINT interval)
    {
        static Scheduler sched(hwnd, db, interval);
        return sched;
    }

    bool run();

    void stop();

};


#endif